package jyj.springmvc.learning.controller;

import jyj.springmvc.learning.dao.UserDao;
import jyj.springmvc.learning.entity.User;
import jyj.springmvc.learning.exception.UserNotExistException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @Author 老顽固小可爱
 * @Date 2022/12/12 20:52
 * @Version 1.0
 */
@Controller
public class UserController {
    @Resource
    private UserDao userDao;

    @RequestMapping("/login")
    public String login(String userName, Model model) {
        User user = userDao.getUserByUserName(userName);
        if (user == null) {
            throw new UserNotExistException();
        }
        return "success";
    }
}
